#include <iostream>
#include <vector>
#define _  ios_base::sync_with_stdio(0),cin.tie(0)
#define int long long
using namespace std;
int f[] = {1,1,2,6,24,120,720,5040,40320};
signed main(){
	_;
	int n,m;
	while(cin>>n>>m){
		vector<int>vt;
		vector<int>ans;
		for(int i=1;i<=n;i++){
			vt.push_back(i);
		}
		m--;
		for(int i=1;i<=n;i++){
			int t;
			if(n-i>8)
			t=m/f[8],m=m%f[8];
			else
			t=m/f[n-i],m=m%f[n-i];
			ans.push_back(vt[t]);
			vt.erase(vt.begin()+t);
		}
		for(int i=0;i<ans.size();i++)
		if(i==0) 
		cout<<ans[i];
		else
		cout<<" "<<ans[i];
		cout<<endl;
	} 

	return 0;
}


